package com.example.floatingpopulation.service.impl;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import com.example.floatingpopulation.controller.request.BaseRequest;
import com.example.floatingpopulation.entity.TemporaryPopulation;
import com.example.floatingpopulation.entity.TemporaryResidencePermit;
import com.example.floatingpopulation.mapper.TemporaryPopulationMapper;
import com.example.floatingpopulation.mapper.TemporaryResidencePermitMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Slf4j
@Service
public class TemporaryResidencePermitServiceImpl implements com.example.floatingpopulation.service.TemporaryResidencePermitService {

    @Autowired
    TemporaryResidencePermitMapper temporaryResidencePermitMapper;
    @Override
    public List<TemporaryResidencePermit> list() {
        return temporaryResidencePermitMapper.list();
    }

    @Override
    public PageInfo<TemporaryResidencePermit> page(BaseRequest baseRequest) {
        PageHelper.startPage(baseRequest.getPageNum(),baseRequest.getPageSize());
        List<TemporaryResidencePermit> users = temporaryResidencePermitMapper.listByCondition(baseRequest);
        return new PageInfo<>(users);
    }

    @Override
    public void save(TemporaryResidencePermit obj) {
        temporaryResidencePermitMapper.save(obj);
    }

    @Override
    public void update(TemporaryResidencePermit obj) {
        obj.setUpdateTime(new Date());
        temporaryResidencePermitMapper.updateById(obj);
    }

    @Override
    public void deleteById(Integer id) {
        temporaryResidencePermitMapper.deleteById(id);
    }
}
